package com.zzw.futures;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author Administrator
 */
@Configuration
public class AsyncAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public ExecutorService commonPool() {
        return Executors.newCachedThreadPool();
    }

    @Bean
    public Async async(ExecutorService commonPool) {
        return new Async(commonPool);
    }
}
